package com.karl.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.karl.dao.UserDao;
import com.karl.entity.User;
import com.karl.service.UserManager;

@Component("userManager")
public class UserManagerImpl implements UserManager {

	private UserDao userDao;

	public UserDao getUserDao() {
		return userDao;
	}
	@Resource
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	/* (non-Javadoc)
	 * @see com.karl.service.impl.UserManager#exists(com.karl.entity.User)
	 */
	@Override
	public boolean exists(User u) {
		return userDao.checkUserExistsWithName(u.getUsername());

	}

	/* (non-Javadoc)
	 * @see com.karl.service.impl.UserManager#add(com.karl.entity.User)
	 */
	@Override
	public void add(User u) {
		userDao.save(u);
	}
	@Override
	public List<User> getUsers() {
		// TODO Auto-generated method stub
		return userDao.getUsers();
	}
	@Override
	public User loadUserById(int id) {
		// TODO Auto-generated method stub
		return userDao.loadUserById(id);
	}
}